<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class='title'>houduren.commm</div>
    <input class='text' placeholder="请输入要标红的字母" type="text">
    <button onclick="btn()">确定</button>
    <script>
        const oTitle = document.querySelector(".title");
        const oInput = document.querySelector(".text");
        
        function btn(){
            const searchValue = oInput.value;
            const reg = new RegExp(searchValue,'g')
            console.log(777,oTitle.innerHTML)
            oTitle.innerHTML = oTitle.innerHTML.replace(reg,search => `<span style="color:red">${search}</span>`)
           
        }

    </script>
</body>
</html>